package main

import (
	fgingrpcgen "fginTpl/fgin_grpc_gen"
	fginhttpgen "fginTpl/fgin_http_gen"
	fginlayout "fginTpl/fgin_layout_gen"
	gingen "fginTpl/gin_gen"
	"fginTpl/utils"
	"flag"
	"fmt"
)

func main() {
	projectName := flag.String("project", "example_server", "服务名")
	path := flag.String("path", "./", "项目路径")
	genType := flag.String("tpl", "gin", "模版类型: gin、fgin_http、fgin_grpc、fgin_layout、fgin_layout_v2")
	flag.Parse()
	// 检测是否符合项目命名规范
	if !utils.IsValidVariableName(*projectName) {
		panic("服务名需符合golang的命名规范,且首字符不能为'_'")
	}
	switch *genType {
	case "gin":
		// 生成命令 .\main.exe -project helloWorld -path ./example -tpl gin
		gingen.GenGin(*projectName, *path)
	case "fgin_http":
		// 生成命令 .\main.exe -project helloWorld -path ./example -tpl fgin_http
		fginhttpgen.GenFGinHttp(*projectName, *path)
	case "fgin_grpc":
		// 生成命令 .\main.exe -project helloWorld -path ./example -tpl fgin_grpc
		fgingrpcgen.GenFGinGrpc(*projectName, *path)
	case "fgin_layout":
		// 生成命令 .\main.exe -project helloWorld -path ./example -tpl fgin_layout
		fginlayout.GenFGinLayout(*projectName, *path)
	case "fgin_layout_v2":
		// 生成命令 .\main.exe -project helloWorld -path ./example -tpl fgin_layout_v2
		fginlayout.GenFGinLayoutV2(*projectName, *path)
	case "fgin_layout_http":
		// 生成命令 .\main.exe -project helloWorld -path ./example -tpl fgin_layout_http
		fginlayout.GenFGinLayoutHttp(*projectName, *path)
	default:
		fmt.Println("模版暂只支持")
		fmt.Println("gin")
		fmt.Println("fgin_http")
		fmt.Println("fgin_grpc")
		fmt.Println("fgin_layout")
		fmt.Println("fgin_layout_v2")
		fmt.Println("fgin_layout_http")
	}
}
